package config

import (
	"github.com/spf13/viper"
	"time"
)

type Config struct {
	Url          string        `mapstructure:"url"`
	Username     string        `mapstructure:"username"`
	Password     string        `mapstructure:"password"`
	ProxyExpired time.Duration `mapstructure:"proxy-expired"`
	MaxUse       uint          `mapstructure:"max-use"`
}

var C Config

func Load() (c Config, err error) {
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath(".")
	if viper.ReadInConfig() == nil {
		err = viper.Unmarshal(&c)
		return
	}
	return
}
